﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

namespace Streaming_Service.Enum {
    public class EnumHelper {
        public static ParentalGuidance GetParentalGuidance(string toParse, ParentalGuidance defaultValue = ParentalGuidance.G) {
            var parsedValue = defaultValue;
            return System.Enum.TryParse(toParse, true, out parsedValue) ? parsedValue : defaultValue;
        }

        public static ParentalGuidance GetParentalGuidanceExt(string toParse,
                                                              ParentalGuidance defaultValue = ParentalGuidance.G) {
            return toParse != null ? GetParentalGuidance(Regex.Replace(toParse, "[^A-Za-z0-9]", ""), defaultValue) : defaultValue;
        }

        public static bool IsTrue(XBool xbool) {
            return xbool == XBool.True;
        }
    }
}